/* --------------------------------------------------------
 * Copyright (c) aeky , Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.server.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aeky.common.EncDecUtil;
import com.aeky.domain.User;
import com.aeky.server.dao.IUserDao;
import com.aeky.server.service.IUserService;

/**
 * 
 * @author aeky
 */
@Service("userService")
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserDao userDao;

    /*
     * 
     * @see com.aeky.server.service.IUserService#addUser(com.aeky.domain.User)
     */
    @Override
    public void addUser(User user) {
        // userDao.add(user);
    }

    /*
     * 
     * @see
     * com.aeky.server.service.IUserService#findUserByLoginName(java.lang.String
     * )
     */
    @Override
    public com.aeky.model.User findUserByLoginName(String loginName, String password) {
        User user = userDao.findUserByLoginName(loginName);
        com.aeky.model.User u = new com.aeky.model.User();
        if (user.getPassword().equals(EncDecUtil.toMd5(password))) {
            u.setLoginName(user.getLoginName());
            u.setRealName(user.getRealName());
            u.setPassword(user.getPassword());
        }
        return u;
    }

    @Override
    public List<User> findAllUser() {
        return userDao.findAllUser();
    }
}
